<template>
  <div class="like">
    <Card>
      <span>猜你喜欢</span>
    </Card>
    <ul>
      <li
        v-for="(item, index) in likeList"
        :key="index"
        @click="toDetail(item.id)"
      >
        <div class="image">
          <!-- 图片懒加载 v-lazy -->
          <img v-lazy="item.imgUrl" atl="" />
        </div>
        <h3>{{ item.name }}</h3>
        <div class="price">
          <span>￥</span>
          <b>{{ item.price }}</b>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import Card from "@/components/home/Card.vue";
//引入第三方插件
// import { Lazyload } from 'mint-ui';
export default {
  name: "Like",
  props: {
    likeList: Array,
  },
  components: {
    Card,
  },
  data() {
    return {};
  },
  created() {
   
  },
  methods: {
    //请求后台商品详情信息
    toDetail(id) {
      this.$router.push({
        name: "Detail",
        query: { id },
      });
    },
  },
};
</script>

<style scoped lang="less">
.like {
  background-color: #fff;
  ul {
    display: flex;
    flex-wrap: wrap;

    li {
      width: 50%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      margin-bottom: 0.5rem;

      .image {
        width: 4.5125rem;
        height: 4.5125rem;
        border-radius: 0.125rem;

        img {
          width: 100%;
          height: 100%;
          border-radius: 0.125rem;
        }
        img[lazy="loading"] {
          background-color: #f7f7f7;
        }
      }

      h3 {
        padding: 0 0.16rem;
        width: 93%;
        color: #222;
        font-size: 0.373333rem;
        font-weight: 400;

        //超出隐藏
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .price {
        width: 93%;
        padding: -0.16rem;
        text-align: left;
        color: #ff0000;

        span {
          font-size: 0.32rem;
        }
        b {
          font-size: 0.426666rem;
          font-weight: 600;
        }
      }
    }
  }
}
</style>
